package com.lian.hope.controller;

import com.lian.hope.model.vo.ProjectsVO;
import com.lian.hope.model.vo.UserWithIdVO;
import com.lian.hope.model.vo.VolunteerActivitiesVO;
import com.lian.hope.service.SearchService;
import com.lian.hope.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search")
@Slf4j
@RequiredArgsConstructor
@Tag(name = "搜索模块相关接口", description = "搜索模块相关接口")
public class SearchController {
    private final SearchService searchService;

    @GetMapping("/project")
    @Operation(summary = "根据名搜索项目")
    public Result<List<ProjectsVO>> findProjectsByName(
        @Parameter(description = "搜索内容") @RequestParam String query) {
        log.info("搜索项目");
        return searchService.queryProjectsByName(query);
    }

    @Operation(summary = "根据名称搜索用户")
    @GetMapping("/user")
    public Result<List<UserWithIdVO>> queryUserByName(@RequestParam String query) {
        log.info("搜索用户");
        return searchService.queryUserByName(query);
    }

    @GetMapping("/activity")
    @Operation(summary = "根据名称搜素活动")
    public Result<List<VolunteerActivitiesVO>> queryActivityByName(
        @Parameter(description = "搜索内容") @RequestParam String query) {
        log.info("搜索活动");
        return searchService.queryActivityByName(query);
    }

}
